package com.dtsmoll.location;

public class LocationUtils {

//    /**
//     * 获取地址信息
//     */
//    public static void getLocation(final Activity activity, final OnLocationCallback callback) {
//        // 判断权限
//        PermissionsUtils.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
//                Manifest.permission.ACCESS_COARSE_LOCATION}, new PermissionsUtils.OnPermissionsCallback() {
//            @Override
//            public void onCallback(boolean status) {
//                if (status) { // 赋予权限
//                    //初始化定位
//                    AMapLocationClient locationClient = new AMapLocationClient(activity.getApplicationContext());
//                    //声明AMapLocationClientOption对象
//                    AMapLocationClientOption clientOption = new AMapLocationClientOption();
//                    //获取一次定位结果：
//                    clientOption.setOnceLocation(true);
//                    locationClient.setLocationOption(clientOption);
//                    //设置定位回调监听
//                    locationClient.setLocationListener(new AMapLocationListener() {
//                        @Override
//                        public void onLocationChanged(AMapLocation amapLocation) {  //异步获取定位结果
//                            if (amapLocation != null) {
//                                if (amapLocation.getErrorCode() == 0) {
//                                    //解析返回定位结果
//                                    callback.onComplete(true, String.format(activity.getString(R.string.address_info),
//                                            amapLocation.getCountry(), amapLocation.getProvince(), amapLocation.getCity(),
//                                            amapLocation.getDistrict()));
//                                }
//                            }
//                        }
//                    });
//                    //启动定位
//                    locationClient.startLocation();
//                } else { // 无权限
//                    callback.onComplete(false, null);
//                }
//            }
//        });
//    }
//
//    public interface OnLocationCallback {
//        void onComplete(boolean status, String address);
//    }
}
